package com.lannuokeji.report;


import javax.servlet.ServletRegistration;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import com.bstek.ureport.console.UReportServlet;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 核心启动类
 * 
 * @author zzu
 *
 */
@SpringBootApplication
@Controller
@ImportResource("classpath:ureport-console-context.xml")
public class MainApplication extends SpringBootServletInitializer {
	
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(MainApplication.class);
	}
	
	public static void main(String[] args) throws Exception {
		SpringApplication.run(MainApplication.class, args);
	}
	
	@Bean
	public ServletRegistrationBean buildUReportServlet() {
		return new ServletRegistrationBean(new UReportServlet(), "/ureport/*");
	}
	
	@GetMapping("/")
    String home() {
        return "forward:/ureport/designer";
    }
}
